package demo.date;

import demo.DateTestMapper;
import java.io.IOException;
import java.io.Reader;
import java.util.Date;
import java.util.List;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import pojo.DateTest;

/**
 * @author 01395265
 * @date 2020/7/27
 */
public class MybatisDateBootStrapDebug {

    public static void main(String[] args) {

        String resource = "mybatis-date-test-config.xml";
        Reader reader;
        try {
            reader = Resources.getResourceAsReader(resource);

            SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
            SqlSession sqlSession = sqlSessionFactory.openSession();

            try {
                DateTestMapper dateTestMapper = sqlSession.getMapper(DateTestMapper.class);
                Date date = new Date(1607649469984L);
                List<DateTest> dateTests = dateTestMapper.selectByDate(date);
                dateTests.forEach(System.out::println);

            } finally {
                sqlSession.close();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
